/******************************************************************************
*
* MODULE:    SumadorParam_TB.v
* DEVICE:     
* PROJECT:   Tarea 1 Diseño Electronico Digital
* AUTHOR:    Ricardo Dávila Castro   
* DATE:      2010 10:36:48
*
* ABSTRACT:   Test Bench del Sumador Parametizable un 4 bit Ejercicio Cuatro b)
*            
*******************************************************************************/
`ifndef 	SUMADORPARAM_TB
`define    SUMADORPARAM_TB


`timescale 1ns / 100ps
module SumadorParam_TB();

parameter LENGTH = 4;

reg [(LENGTH-1):0]inA;
reg [(LENGTH-1):0]inB;
reg Cin;
reg [(LENGTH):0]Suma;
integer unsigned  i=0;
wire[(LENGTH):0]FullAdder;
wire Cout;


initial begin
		
		inA = 0;
		forever #160 inA = inA + 'b1;
	end

initial 
	begin
		inB = 0;
		forever #10 inB = inB + 'b1;
	end

initial 
	begin
		Cin = 0;
		forever #5 Cin =~Cin;
	end

always @ (inA ,inB,Cin)
	begin
		Suma = inA + inB + Cin; 
		i=i+1;
		 
		//$display("FullAdder %d , Suma %d --> %d",FullAdder,Suma,i);
	 #1 if (FullAdder != Suma) 
			$display("%d + %d + %d, el resultado %d es incorrecto, el resultado correcto es %d, combinacion %d " ,inA,inB,Cin,FullAdder,Suma,i);//,Cout);
		else 
			$display("%d + %d + %d, el resultado %d . Suma correcta combinacion %d",inA,inB,Cin,FullAdder,i);
	end

SumadorParam InstSumaParam(.inA(inA),.inB(inB),.Cin(Cin),.Cout(FullAdder[4])/*.Cout(Cout)*/,.ResSum(FullAdder));//.ResSum(FullAdder[(LENGTH)-1:0]));
endmodule
`endif